import React from 'react';
import { Input } from 'antd';
const { TextArea } = Input;

const SingleInput = (props, ref) => {
  const { valueType, value, onChange, fieldProps = {} } = props;
  const { placeholder = '请输入' } = fieldProps
  return (
    valueType !== 'textarea' ? 
      <Input
        style={{ width: '100%' }}
        placeholder={placeholder}
        {...fieldProps}
        value={value}
        onChange={(e) => {
          onChange(e.target.value);
        }}
      />
      : <TextArea
        style={{ width: '100%' }}
        placeholder={placeholder}
        value={value}
        {...fieldProps}
        onChange={(e) => {
          onChange(e.target.value);
        }}
      />
  );
};

export default React.forwardRef(SingleInput);
